package com.learn.demo.netty.io;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * long转byte编码器
 *
 * @author banjiawei
 * @date 2021/08/03
 */
public class MyLongToByteEncoder extends MessageToByteEncoder<Long> {

    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, Long aLong, ByteBuf byteBuf) throws Exception {
        System.out.println("MyLongToByteEncoder 被调用");
        System.out.println("msg " + aLong);
        byteBuf.writeLong(aLong);
    }
}
